﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using EYSLibrary;

namespace EYayincilikSistemi
{
     public partial class MakaleDuzeltme : System.Web.UI.Page
     {
          protected void Page_Load(object sender, EventArgs e)
          {
               using (EYayincilikDBEntities eys = new EYayincilikDBEntities())
               {
                    //Referans ekle checkbox listesini doldur
                    int YazarId=1;
                    int durum=2;
                    var makaleler = from Makale in eys.Makale
                                    where Makale.YazarId == YazarId && Makale.MakaleDurum == durum
                                    select Makale;

                    IList<Makale> makaleList = makaleler.ToList<Makale>();


                    DropDownList1.DataSource = makaleList;
                    DropDownList1.DataTextField = "Baslik";
                    DropDownList1.DataValueField = "MakaleId";
                    DropDownList1.DataBind();

                }
          }

          protected void Button1_Click(object sender, EventArgs e)
          {
               int makaleId = Convert.ToInt32(DropDownList1.SelectedValue);
               using (EYayincilikDBEntities eys = new EYayincilikDBEntities())
               {
                    var makale = (from Makale in eys.Makale
                                 where Makale.MakaleId== makaleId
                                 select Makale).FirstOrDefault();
                    makale.Metin = TextBox1.Text;
                    eys.SaveChanges();
               }

          }
     }
}